#pragma once
#include <XnCppWrapper.h>
#include <functional>
#include <iostream>
#include <vector>
#include "Effect.h"
#include "Kamehameha.h"
#include "SoundController.h"
using namespace std;
using namespace xn;

enum EAction {
	EAction_None = 0,
	EAction_Boomerang_R,
	EAction_Boomerang_L,
	EAction_Kamehameha,
	EAction_Guard,
	EAction_MAX
};

struct ActionInfo {
	EAction ActionType;
	XnPoint3D start;
	XnVector3D direction;
	float magnitude;
	bool removable;
	Effect* effect;
	SoundType soundType;
	bool enabled;
	XnUInt32 userID;
};

/* Abstract Class */
class ActionChecker
{
public:
	ActionChecker(int funcNum, bool movable);
	virtual ~ActionChecker();
	bool Check(const JointInfo& joints, XnUInt32 userID);
	void ResetAction() { _frame = _func_No = 0; this->OnResetAction(); };
	virtual bool IsActionExcluding() { return false; }
	virtual ActionInfo* GetActionInfo() = 0;
	virtual const char* GetActionStr() const = 0;
	virtual void DrawEffects() {};
protected:
	void ResetFrame() { _frame = 0; }
	int NowFrame() { return _frame; }
	XnSkeletonJointPosition* GetPositionsHistory(int no) { return _jointHistory[no]; }
	const int Func_Num;
	function<bool (const JointInfo&)> *Functions;
	int *Interval_frame;
	int GetNowFuncNo() const { return _func_No; };
	virtual void SetActionInfo(const JointInfo&, XnUInt32 userID, bool ifChange) {};
	virtual void OnTimeout() {};
	virtual void OnActionDetected() {};
	virtual void OnResetAction() {};
private:
	JointInfo *_jointHistory;
	int _func_No;
	int _frame;
	bool _movable;
};

